
/**
 * Written by :
 * @author Floz
 * www.floz.fr || www.minuit4.fr
 */
package fr.tilzy.core.layers 
{
	
	public class LayerEnum 
	{
		
		// - PRIVATE VARIABLES -----------------------------------------------------------
		
		private static const LIST:Vector.<LayerEnum> = new Vector.<LayerEnum>();
		
		// - PUBLIC VARIABLES ------------------------------------------------------------
		
		public static const BACKGROUND:LayerEnum = new LayerEnum( "background", 0 );
		public static const FLOOR:LayerEnum = new LayerEnum( "floor", 1 );
		public static const MOBILES:LayerEnum = new LayerEnum( "mobiles", 2 );
		public static const FOREGROUND:LayerEnum = new LayerEnum( "foreground", 3 );
		
		public var id:String;
		public var depth:int;
		
		// - CONSTRUCTOR -----------------------------------------------------------------
		
		public function LayerEnum( id:String, depth:int ) 
		{
			this.id = id;
			this.depth = depth;
			
			LIST[ LIST.length ] = this;
		}
		
		// - EVENTS HANDLERS -------------------------------------------------------------
		
		// - PRIVATE METHODS -------------------------------------------------------------
		
		// - PUBLIC METHODS --------------------------------------------------------------
		
		public static function getById( id:String ):LayerEnum
		{
			var i:int = LIST.length;
			while ( --i > -1 )
				if ( LIST[ i ].id == id ) return LIST[ i ];
			
			return null;
		}
		
		public static function getByDepth( depth:int ):LayerEnum 
		{
			var i:int = LIST.length;
			while ( --i > -1 )
				if ( LIST[ i ].depth == depth ) return LIST[ i ];
			
			return null;
		}
		
		public function valueOf():int 
		{
			return depth;
		}
		
		public function toString():String
		{
			return id;
		}
		
		// - GETTERS & SETTERS -----------------------------------------------------------
		
	}
	
}